Add content_type support for fiction vs cartoon storylines#1216
Conversation
Adds a content_type column to storylines (default 'fiction') to distinguish fiction from cartoon content. The index endpoint validates the field, the update endpoint allows admin changes, and story cards/detail pages display a Cartoon badge when applicable. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
realproject7
left a comment
There was a problem hiding this comment.
RE2 Review: ✅ Approve
Clean implementation — migration is safe (NOT NULL DEFAULT won't break existing rows), API validation is correct with shared CONTENT_TYPES constant, admin-only gate on updates is properly enforced with 403, and badge rendering follows existing patterns.
Minor non-blocking note: no CHECK constraint on the column, so direct DB inserts could bypass validation. This is consistent with how genre/language are handled in the codebase, so not a blocker.
CI: lint-and-typecheck green, e2e pending at time of review.
project7-interns
left a comment
There was a problem hiding this comment.
Verdict: REQUEST CHANGES
Summary
The PR implements the main API/UI wiring for content_type, but the allowed value contract is not fully enforced. Invalid supplied values can still silently become fiction, and the database does not protect the foundational storylines.content_type column from out-of-band invalid writes.
Findings
-
[medium] Invalid non-string/falsy
contentTypevalues are accepted as the defaultfictioninstead of being rejected with 400.- File:
src/app/api/index/storyline/route.ts:49 - Suggestion: Validate based on property presence, not truthiness. For example, when
contentTypeis present, require it to be a string and one ofCONTENT_TYPES; only default tofictionwhen the field is absent.
- File:
-
[medium] The migration adds
content_typewithout a database constraint, so the stated allowed values are not enforced at the source of truth.- File:
supabase/migrations/00039_add_content_type.sql:2 - Suggestion: Add a CHECK constraint such as
content_type IN ('fiction', 'cartoon'), ideally named, so admin SQL, service-role jobs, or future endpoints cannot persist unsupported content types.
- File:
Decision
Requesting changes because #1212 defines content_type as the foundation for downstream cartoon work. That field needs strict value enforcement before later tickets depend on it. Note: lint/typecheck is green, but e2e was still pending at review time.
…aint - Reject non-string/invalid contentType with 400 when field is present - Add CHECK constraint to migration ensuring only fiction/cartoon persisted Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
project7-interns
left a comment
There was a problem hiding this comment.
Verdict: APPROVE
Summary
The requested fixes are in place. contentType is now rejected when present but non-string/invalid, and the migration adds a named CHECK constraint enforcing fiction/cartoon at the database layer.
Findings
- None blocking.
Decision
Approved. The prior RE1 findings are resolved. lint-and-typecheck is green on the updated commit; e2e was still pending at approval time and should be verified before merge.
realproject7
left a comment
There was a problem hiding this comment.
RE2 Re-review: ✅ Approve
Both fixes correctly address RE1's findings:
- Strict validation — uses
"contentType" in bodyfor presence check, rejects non-string/invalid with 400, only defaults to fiction when field is absent. - CHECK constraint added to migration — DB-level enforcement now in place.
lint-and-typecheck green. e2e pending. No further concerns from RE2.
Summary
content_typecolumn (fiction|cartoon, defaultfiction) to storylines table via migration/api/index/storylineaccepts and validatescontentTypeparam, rejects invalid values with 400/api/storyline/updateallows admin-only updates tocontent_typeCONTENT_TYPESconstant, unit tests for badge and validationCloses #1212
Test plan
fictionfor existing rows after migration🤖 Generated with Claude Code